local joy__shanshan = fk.CreateSkill {

  name = "joy__shanshan",

  tags = { Skill.Compulsory, },

}



joy__shanshan:addEffect("viewas", {
  name = "joy__shanshan",
  anim_type = "defensive",
  pattern = "jink",
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeEquip
  end,
  view_as = function(self, player,cards)
    if #cards ~= 1 then return nil end
    local c = Fk:cloneCard("jink")
    c.skillName = joy__shanshan.name
    c:addSubcard(cards[1])
    return c
  end,
})

joy__shanshan:addEffect(fk.TargetConfirmed, {
  name = "#joy__shanshan_trigger",
  mute = true,
  --joy__shanshan,
  events = {fk.TargetConfirmed},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return data.from ~= player.id and target == player and player:hasSkill(joy__shanshan.name) and (data.card.trueName == "slash" or data.card:isCommonTrick())
  end,
  on_cost = function (self, event, target, player, data)
    local card = player.room:askForResponse(player, "jink", "jink", "#joy__shanshan-card:::"..data.card:toLogString(), true)
    if card then
      event:setCostData(self, card)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:responseCard{
      from = player.id,
      card = event:getCostData(self),
    }
    table.insertIfNeed(data.nullifiedTargets, player.id)
    if not player.dead then
      player:drawCards(1, joy__shanshan.name)
    end
  end,
})

return joy__shanshan